﻿using Shop.Collect;
using Shop.Model.Stock;
using Shop.RemoteModel.Stock.Model;
using Shop.Service.Interface;

namespace Shop.Service.lmpl
{
    internal class StockService : IStockService
    {
        private readonly IGoodsSkuCollect _Sku;
        private readonly IGoodsStockCollect _Stock;

        public StockService (IGoodsSkuCollect sku,
            IGoodsStockCollect stock)
        {
            this._Sku = sku;
            this._Stock = stock;
        }
        public int GetStockNum (long skuId)
        {
            return this._Stock.GetStock(skuId);
        }
        public bool Add (SkuStockAdd arg)
        {
            long goodsId = this._Sku.GetGoodsId(arg.SkuId);
            return this._Stock.AddStock(new StockAdd
            {
                GoodsId = goodsId,
                SkuId = arg.SkuId,
                UserId = arg.UserId,
                Stock = arg.Stock
            });
        }
    }
}
